﻿using MyTodo.Common.Models;
using Prism.Commands;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;

namespace MyTodo.ViewModels
{
    public class NotebookViewViewModel : BindableBase
    {
        private ObservableCollection<TodoDto> todoDtos;
        public DelegateCommand OpenRightDrawerCommand { get; private set; }

        public NotebookViewViewModel()
        {
            TodoDtos = CreateTodos();
            OpenRightDrawerCommand = new DelegateCommand(OpenRightDrawer);
        }

        private void OpenRightDrawer()
        {
            IsRightDrawerOpen = !IsRightDrawerOpen;
        }

        private ObservableCollection<TodoDto> CreateTodos()
        {
            var todoDtos = new ObservableCollection<TodoDto>();
            for (int i = 0; i < 20; i++)
            {
                TodoDto todoDto = new TodoDto();
                todoDto.Title = $"第{i}备忘录";
                todoDto.Description = $"哇啦哇啦....";
                todoDtos.Add(todoDto);
            }

            return todoDtos;
        }


        private bool isRightDrawerOpen;

        public bool IsRightDrawerOpen
        {
            get { return isRightDrawerOpen; }
            set
            {
                isRightDrawerOpen = value;
                RaisePropertyChanged();
            }
        }

        public ObservableCollection<TodoDto> TodoDtos
        {
            get { return todoDtos; }
            set
            {
                todoDtos = value;
                RaisePropertyChanged();
            }
        }

    }
}
